package org.alanlau.springjpa.service;

import org.alanlau.springjpa.entity.Person;
import org.alanlau.springjpa.repository.PersonRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Person 服务层
 *
 * @author Alan
 * @data 2019/10/13 18:21
 */
@Service
public class PersonService {
    @Autowired
    PersonRepository personRepository;

    public List<Person> getPersons() {
        return personRepository.findAll();
    }

    public void save(String name) {
        Person person = new Person();
        person.setName(name);
        person.setAge(33);

        personRepository.save(person);
    }

    public List<Person> findNativeByName(String name) {
        return personRepository.findNativeByName(name);
    }

    public List<Person> findPersonName(String name) {
        return personRepository.findPersonName(name);
    }
}
